<?php
	
	application::addHeaderCSS("application/template/default/dhtmlx/dhtmlxLayout/codebase/dhtmlxlayout.css");
	application::addHeaderCSS("application/template/default/dhtmlx/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_skyblue.css");
	
	application::addHeaderJS("application/template/default/dhtmlx/dhtmlxLayout/codebase/dhtmlxcommon.js");
	application::addHeaderJS("application/template/default/dhtmlx/dhtmlxLayout/codebase/dhtmlxlayout.js");
	application::addHeaderJS("application/template/default/dhtmlx/dhtmlxLayout/codebase/dhtmlxcontainer.js");
	
	
	
	application::addHeaderCSS("application/template/default/dhtmlx/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css");
	application::addHeaderJS("application/template/default/dhtmlx/dhtmlxForm/codebase/dhtmlxform.js");
	
	
	
	application::addHeaderCSS("application/template/default/dhtmlx/dhtmlx_std_full/dhtmlx.css");
	application::addHeaderJS("application/template/default/dhtmlx/dhtmlx_std_full/dhtmlx.js");
	
?>
<style>
		html, body {
			width: 100%;
			height: 100%;
			margin: 0px;
			padding: 0px;
			overflow: hidden;
		}
	</style>
	
<div id="parentId" style="width: 100%;height: 100%;	margin: 0px;padding: 0px; overflow: hidden;"></div>

<div id="content" style="position: relative; top: 20px; left: 20px; width: 600px; height: 400px; aborder: #B5CDE4 1px solid;">

<div style="width:350px;height:30px;">
	<div id="form_container" style="width:350px;height:auto;"></div>
	<a href="index.php" >Volta para o início</a>
</div>

	
		
</div>



<script>
var dhxLayout;
function doOnLoad() {
    dhxLayout = new dhtmlXLayoutObject("parentId", "1C");
    dhxLayout.cells("a").setText("Cadastro de usuário");
    dhxLayout.cells("a").attachObject("content");
}
doOnLoad();
</script>


<div id="idObj"></div>
<script>
		var myForm, formData;
		function doOnLoad2() {
		        formData = [
		        			{type:"settings", position:"label-top"},
                           { type: "fieldset", name: "data", label: "Criar Conta de Usuário", inputWidth: "auto", list:[
								{type:"input", name: 'name', label:'Nome'},
								{type:"input", name: 'lastname', label:'Sobrenome'},
								{type:"input", name: 'email', label:'e-mail'},
								{type:"input", name: 'confirmemail', label:'Confirmar e-mail'},
								{type:"password", name:"password", label:"Senha"},
								{type:"password", name:"confirmpass", label:"Confirme sua senha"},
								{type:"button", name:"save", value:"Criar agora"}] 
							   }
                        	]
			myForm = new dhtmlXForm("form_container", formData);
			
			//myform.dataFeed("data/form.php");//specify here the path to a file which will get change requests
			//myform.bind(mygrid);
			
			id='save';
			myForm.attachEvent("onButtonClick", function(id){

     			myForm.send("index.php?webservice=true&component=login&controller=login&task=save","post", function(loader, response){
  					sendActionResponse( response );
  					
  				});  					
     		
			});
			

		}	
		
		function sendActionResponse( response ){
			
			response	=	parseInt(response);
						
			switch(response){
				case	1:
				
					//alert('Conta de usuário criada com sucesso.');
					
					dhtmlx.alert({
					    title:"Alerta",
					    type:"alert",
					    text:"Conta de usuário criada com sucesso.\nAgradecemos pela colaboração.",
					    ok:"Autenticar agora",
					    callback: function() {window.location.href='index.php';}
					});

					break;
				case	2:
				
					dhtmlx.alert({
					    title:"Alerta",
					    type:"alert-error",
					    text:"Ocorreu um erro ao tentar criar sua conta de usuário, favor tentar novamente mais tarde.",
					    callback: function() {window.location.href='index.php';}
					});
				
					break;
				case	3:
				
					break;
				default:
				
					alert('Erro no cadastro, favor tentar novamente mais tarde.');					
			}
		}
		doOnLoad2();
</script>

